<extend name="Public:main" />

<block name="subnavbar"></block>

<block name="container">
<div class="account-container">
	<form id="login_form" method="post" action="__APP__/Index/login">
		<h2>用户登录</h2>
		<p>{$messages}</p>
		<div class="form-group">
			<input type="text" name="username" class="form-control" placeholder="请输入账号" maxlength="32" autofocus="autofocus" />
		</div>
		<div class="form-group">
			<input type="password" name="password" class="form-control" placeholder="请输入密码" maxlength="32" />
		</div>
		<div class="form-group">
			<input type="text" name="verify" class="form-control" placeholder="请输入验证码" maxlength="8" />
		</div>
		<div class="form-group">
			<img id="verify" src="__APP__/Index/verify" width="160" height="50" class="img-rounded" style="cursor:pointer;" />
		</div>
		<div class="pull-left">
			<button type="submit" class="btn btn-success">登录</button>
		</div>
		<div class="pull-right">
			<a id="forget">忘记密码？</a>
		</div>
	</form>
</div>
<div class="login-extra">
	还没有账号?&nbsp;<a id="register_foot">立即注册</a>
</div>
</block>

<block name="script">
<script>
$(function(){
	jQuery.validator.addMethod("lettersonly", function(value, element) {
		return this.optional(element) || /^[^:%,'\*\"\s\<\>\&]+$/i.test(value);
	}, "不得含有特殊字符");
	
	$('#login_form').validate({
		errorElement:'span',
		rules:{
			username:{required:true, lettersonly:true},
			password:{required:true},
			verify:{required:true}
		}
	});

	$("#verify").click(function() {
		$("#verify").attr("src", "./verify?k="+Math.random());
	});

	var registerNo = function(){
		swal({
			type: 'error',
			title: '暂未开放注册',
			allowOutsideClick: false,
			allowEnterKey: false,
			confirmButtonText: '确认',
			animation: false,
			customClass: 'animated wobble'
		});
	};
	
	$("#register_nav").click(registerNo);
	$("#register_foot").click(registerNo);
	$("#forget").click(registerNo);
});
</script>
</block>